package com.lightjet.macross.base.awf.util;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.lightjet.macross.base.awf.dto.ProcInstDTO;
import com.lightjet.macross.common.util.FormatUtil;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;

public class DTOConvertUtil {
    @JsonIgnore
    public static ProcInstDTO FromProcessInstance(ProcessInstance p)
    {
        return new ProcInstDTO(p.getId(),p.getName(), FormatUtil.GetDateTimeStr(p.getStartTime()),p.getStartUserId(),"","","");
    }

    @JsonIgnore
    public static ProcInstDTO FromProcessInstance(ProcessInstance p, Task task)
    {
        if(task!=null) {
            return new ProcInstDTO(p.getId(), p.getName(), FormatUtil.GetDateTimeStr(p.getStartTime()), p.getStartUserId(), task.getId(), task.getTaskDefinitionKey(), task.getName());
        }
        else
        {
            return new ProcInstDTO(p.getId(), p.getName(), FormatUtil.GetDateTimeStr(p.getStartTime()), p.getStartUserId(), "", "", "-");
        }
    }
}
